#include "tgs.h"
using namespace TagLib;

Tag *get_mp3tgs(char *fname)
{
    TagLib::MPEG::File mp3file(fname);
    if  (mp3file.ID3v2)
        return mp3file.ID3v2Tag();
    if (mp3file.APE)
        return mp3file.APETag();
    return NULL;
}

Tag *get_oggtgs(char *fname)
{
   /* TagLib::Ogg::PageHeader a;
    if (oggfile.isValid())
        return oggfile.tag();*/
    return NULL;
}

Tag *get_flactgs(char *fname)
{
    TagLib::FLAC::File flacfile(fname);
    if (flacfile.ID3v2Tag())
        return flacfile.ID3v2Tag();
    if (flacfile.tag())
        return flacfile.tag();
    return NULL;
}


Tag *get_apetgs(char *fname)
{
    TagLib::APE::File apefile(fname);
    if (apefile.isValid())
        return apefile.tag();
    return NULL;
}


Tag *get_mp4tgs(char *fname)
{
    TagLib::MP4::File mp4file(fname);
    if (mp4file.isValid())
        return mp4file.tag();
    return NULL;
}


Tag *get_tags(char *fname)
{
    Tag *res = get_mp3tgs(fname);
    if (res != NULL)
        return res;

    res = get_oggtgs(fname);
    if (res != NULL)
        return res;

    res = get_flactgs(fname);
    if (res != NULL)
        return res;

    res = get_apetgs(fname);
    if (res != NULL)
        return res;

    res = get_mp4tgs(fname);
    if (res != NULL)
        return res;


    return NULL;
}
